Maybe Accessing Null Reference (MANR)

Description:

MANR detects situations where the value of the left operand of the . (field access) operation may be nil.

Incorrect:

Compiler = class
    public
      procedure errors(msg:MyMessage);
      procedure compile(str:String);
end;
...
procedure Compiler.errors(msg:MyMessage);
begin
  raise ApplicationException.Create(msg.getText());
end;

procedure Compiler.compile(str:String);
begin
  if str = nil then 
     errors(nil);
  ...
end;

Correct:

Compiler = class
    public
      procedure errors(msg:MyMessage);
      procedure compile(str:String);
end;
...
procedure Compiler.errors(msg:MyMessage);
begin
  if msg <> nil then 
     raise ApplicationException.Create(msg.getText())
  else
     raise ApplicationException.Create();
end;

procedure Compiler.compile(str:String);
begin
  if str = nil then 
     errors(nil);
  ...
end;